function includes(string, substring) {
  let start = 0
  let stringLength = string.length
  let subLength = substring.length
  for (let i = 0; i < stringLength; i++) {
    if (string[i] === substring[0]) {
      start = i
      break
    }
  }
  if (!start || stringLength - start < subLength) return false
  for (let i = start; i < stringLength; i++) {
    if (string[i] !== substring[i - start]) return false
  }
  return true
}

console.log(includes('abcdefg', 'ab'))
